home *** CD-ROM | disk | FTP | other *** search
/ Programmers Heaven 2 / Programmers Heaven 2.iso / files / graphics / library / wgt51_r2.zip / WGT5 / EXAMPLES / WGT44.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-03  |  2.8 KB  |  82 lines

  1. /*
  2. ==============================================================================
  3.                       WordUp Graphics Toolkit Version 5.0                     
  4.                              Demonstration Program 44                         
  5.                                                                               
  6.  Displays the status of the keyboard flags.  Try pressing the numlock,       
  7.  scrlock, capslock, shift, ctrl and alt keys.                                
  8.                                                                               
  9.  Once a key other than those listed above is hit, it then flashes the        
  10.  keyboard LEDS in sequence.                                                  
  11.                                                                               
  12.  *** PROJECT ***                                                             
  13.  This program requires the WGT5_WC.LIB file to be linked.                    
  14.                                                                               
  15.  *** DATA FILES ***                                                          
  16.  None.                                                                       
  17.                                                            WATCOM C++ VERSION 
  18. ==============================================================================
  19. */
  20.  
  21. #include <wgt5.h>
  22.  
  23. void main(void)
  24. {
  25.   printf ("WGT Example #44\n\n");
  26.   printf ("Control of the keyboard status keys is demonstrated.\n");
  27.   printf ("Press a key to abort key detection and force keys to be lighted.\n");
  28.   printf ("Another keypress will end the program.\n");
  29.   printf ("\n\nPress any key to continue.\n");
  30.   getch ();
  31.  
  32.    wsetmode (3);
  33.    do {
  34.      if (wget_numlock ())  
  35.        printf ("NUMLOCK  ");
  36.      if (wget_capslock ()) 
  37.        printf ("CAPSLOCK  ");
  38.      if (wget_scrlock ())  
  39.        printf ("SCRLOCK  ");
  40.      if (wget_lshift ())   
  41.        printf ("LSHIFT  ");
  42.      if (wget_rshift ())   
  43.        printf ("RSHIFT  ");
  44.      if (wget_lalt ())     
  45.        printf ("LALT  ");
  46.      if (wget_ralt ())     
  47.        printf ("RALT  ");
  48.      if (wget_lctrl ())     
  49.        printf ("LCTRL  ");
  50.      if (wget_rctrl ())     
  51.        printf ("RCTRL  ");
  52.      printf ("\n");
  53.    } while (!kbhit ());
  54.  
  55.    getch ();
  56.  
  57.    wset_numlock (0);
  58.    wset_capslock (0);
  59.    wset_scrlock (0);
  60.    do {
  61.      wset_numlock (1); /* For some reason, this must be done twice ? */
  62.      delay (100); 
  63.      wset_numlock (1); 
  64.      delay (100); 
  65.      wset_numlock (0); 
  66.      delay (100); 
  67.      wset_capslock (1); 
  68.      delay (100); 
  69.      wset_capslock (0);
  70.      delay (100);
  71.      wset_scrlock (1); 
  72.      delay (100); 
  73.      wset_scrlock (0);
  74.      delay (100);
  75.    } while (!kbhit ());
  76.    getch ();
  77.  
  78.    wset_numlock (1);
  79.    wset_capslock (0);
  80.    wset_scrlock (0);
  81. }
  82.